home *** CD-ROM | disk | FTP | other *** search
- Path: inforamp.net!ts14-03
- From: rmorin@inforamp.net (Randy Charles Morin)
- Newsgroups: comp.lang.c++
- Subject: Re: Coding Standards
- Date: Sat, 16 Mar 96 08:03:03 GMT
- Organization: MiddleWorld SoftWare
- Message-ID: <4idskb$pc1@sam.inforamp.net>
- References: <4hj8ek$elu@sam.inforamp.net> <4hktar$5o2@galaxy.ucr.edu> <4hmqol$97j@abacus.abasoft.co.uk> <4hsg8r$pmm@sam.inforamp.net> <4i9o6j$p4l@daisy.pgh.wec.com>
- NNTP-Posting-Host: ts14-03.tor.inforamp.net
- X-Newsreader: News Xpress Version 1.0 Beta #4
-
- In article <4i9o6j$p4l@daisy.pgh.wec.com>,
- zcewj@cnfd.pgh.wec.com (Elliot W. Jackson) wrote:
- >Without passing judgement at all on your knowledge or experience level, I
- >suggest that it might be worth your while to re-examine your position. The
- >wise man will recognize that when he begins to think "The whole world is
- >wrong but me!", that usually (but not always) means that it is time for a
- >little re-evaluation.
-
- You see, I've worked on dozens of projects and most of them had coding
- standards. And most of those coding standards were reasonable. This coding
- standard was a joke. You see, the company even agreed that our group would
- not have to follow the guidelines, because they were devised by an
- inexperienced group that were not aware of the world outside of character
- based Unix. But, a couple of you inexperienced programmers have to pull a
- hollier than thou routine. I received many responses from users who agreed
- that the standards were a joke. Some of these were even posted publicly. So
- your me against the world philosophy is as ridiculous as agreeing with any of
- those standards. I'll go over more in detail now, why these standards are a
- joke.
-
- Agrivar
-
- -------
- -source files should have the extension .cc (not .cpp or .c).
- I don't think I have to say anything here.
-
- -header files should have the extension .hh (not .hpp or .h).
- I don't think I have to say anything here.
-
- -inline C++ functions should be in a file with the extension .icc (not
- in the primary header).
- I don't think I have to say anything here either. But, I
- will. Although I've seen many people do this, it is contrary to normal
- industry practices. By using non-standard practices you increase the learning
- necessary for new employees. Bad.
-
- -do not use the /* */ comment, except when commenting out entire
- sections of code.
- /* */ are the ANSI standard comment. // are not. When you have a
- parameter not used warning, you should eliminate it using.
- void f(int /* idControl */);
- You can't do this with //. You could also delete the identifier, but then you
- would lose context.
-
- -a class which can be instantiated with a "new" must have a copy
- constructor, a destructor and an assignment operator definition.
- Most compilers (if not all) supply default copy construtors. Unless
- you think your class may have copy behavior problems, then writing copy
- constructors is redundant. When you have 100+ classes to write and where the
- average copy constructor has 50 lines, you would need 100 hours to write the
- additional robustness (or cumbersomeness).
-
- -never use #define instead or const.
- This is a good debate, but I still maintain that if your memory model
- and compiler make #define data text and const code text, then you cannot
- consider this a straight forward trade-off.
-
- -variable are to be declared with the smallest possible scope.
- I'll leave this one alone. I was only trying to enlargen the joke
- with a funny example. This served the purpose. Generally this practice is
- good.
-
- -don't use explicit type conversions.
- Anybody who has done heavy C++ programming knows how ridiculous this
- rule is. This is easy to implement in C, but impossible in the C++ Windows
- environment.
-
- -don't use implicit type conversions implicitly, use them explicitly.
- See the previous rule.
-
- -every case statement must be terminated with a break statement.
- Why? This is arbitrary and makes some programming algorithms harder
- to implement. Example: the messages handling switch statement. You usually
- break to fall to the default handling and return to skip the default handling.
-
- -don't use conditional compilation preprocessor directives.
- This is simply stupid. The writers of the standard simply were not
- aware of cross-platform development techniques.
-
- -optimize code only when you have a problem.
- Why not anticipate the problem?
-
- -access functions are to be inline.
- This is the biggest fallacy in programming today. If you make your
- accessors inline, then you have defeated the purpose of data hiding. If your
- data's type changes, then you still have to recompile every object that
- accesses the member.
-
- -give protected accessors for all data members.
- Proper encapsulation tells us otherwise.
-
- -++ and -- operations should be on a separate line.
- This one is arbitrary. I've heard people argue for this standard, but
- their only reason is that they say it is less buggy and easily debugged. I
- just don't see why.
-
- -don't allocate memory and expected someone else will delete it later.
- Every project I've ever worked on had some feature that just blew this
- standard into hell.
-
- Agrivar
-